package com.java.exer_4;

public class Poker implements Cloneable {
    //花色： 0~3   0：黑桃  1：红桃   2：梅花   3：方块
    private String type;
    //数值： 1~13
    private int num;

    public Poker(String type, int num) {

        this.type = type;
        this.num = num;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    //浅拷贝
    @Override
    protected Object clone() throws CloneNotSupportedException {
        Poker poker = (Poker) super.clone();
        poker.setType(new String(this.type));
//       Poker poker=new Poker(this.type,this.num);
//        Poker poker=(this.num,new(this.type));

        return poker;
    }

    @Override
    public String toString() {
        return "Poker{" +
                "type='" + type + '\'' +
                ", num=" + num +
                '}';
    }
}